package com.tongji.housediy.view.components
{
	import com.tongji.housediy.utils.ConstVariableInventory;
	
	import flash.display.BlendMode;
	import flash.display.CapsStyle;
	import flash.display.GraphicsPath;
	import flash.display.GraphicsPathCommand;
	import flash.display.GraphicsSolidFill;
	import flash.display.GraphicsStroke;
	import flash.display.IGraphicsData;
	import flash.display.JointStyle;
	import flash.events.Event;
	
	import mx.core.UIComponent;
	
	/**
	 * 
	 * @author chenchao
	 * 
	 */
	public class OpeningWall extends AbstractBorderChild
	{
		private var graphicsData:Vector.<IGraphicsData>;
		
		private var stroke:GraphicsStroke;
		private var commands:Vector.<int>;
		
		////////////////////////by zazisb
		public var oppositeWall:OpeningWall;
		////////////////////////////////////
		
		public function OpeningWall(newLength:Number = 0)
		{
			data = new Vector.<Number>();
			data.push(0, 0);
			data.push(0, (newLength == 0) ? ConstVariableInventory.OPENING_WALL_LENGTH : newLength);
			
			initialData = new Vector.<Number>();
			initialData.push(0, 0);
			initialData.push(0, (newLength == 0) ? ConstVariableInventory.OPENING_WALL_LENGTH : newLength);
			
			this.dragType = "openingFormat";
			
			super();
			
			this.length = (newLength == 0) ? ConstVariableInventory.OPENING_WALL_LENGTH : newLength;
			
			var solidFill:GraphicsSolidFill = new GraphicsSolidFill(0xffffff);
			stroke = new GraphicsStroke(8, false, "normal", CapsStyle.SQUARE, JointStyle.MITER, 3, solidFill);
			
			commands = new Vector.<int>();
			commands.push(GraphicsPathCommand.MOVE_TO);
			commands.push(GraphicsPathCommand.LINE_TO);
			
			this.firstVertex.visible = true;
			this.secondVertex.visible = true;
			
			draw();
		}
		
		override public function clone():AbstractBorderChild
		{
			var newChild:OpeningWall = new OpeningWall(this.length);
			return newChild;
		}
		
		override protected function draw():void
		{
			this.graphics.clear();
			var path:GraphicsPath = new GraphicsPath(commands, initialData);
			
			graphicsData = new Vector.<IGraphicsData>();
			graphicsData.push(stroke);
			graphicsData.push(path);
			
			this.graphics.drawGraphicsData(graphicsData);
		}
	}
}